<?php 
    include_once('../../sys/sys.php');
    include_once('../178config.php');
    
    header('Content-Type: text/html; charset=utf-8');
    $st = $_GET['st'];
    if(is_null($st)){$st = 0;}
    $name = trim($_GET['name']);
    
    $totalnumbers = get_count_of_field('178_tags','name like "%' . $name . '%"');
?>
Ext.setup({
    tabletStartupScreen: 'tablet_startup.png',
    phoneStartupScreen: 'phone_startup.png',
    icon: 'icon.png',
    glossOnIcon: false,
    onReady : function() {
        Ext.regModel('Nl', {
            fields: ['nName', 'upDate', 'id']
        });
        var store = new Ext.data.Store({
                model: 'Nl',
                sorters: 'nName',
                getGroupString : function(record) {
                    //return (record.get('upDate')[5] + record.get('upDate')[6]);
                    return (record.get('nName')[0]);
                },
                proxy: {
                    type: 'ajax',
                    url : '<?php echo SITE_URL_MB; ?>mb178/pskw<?php echo $name; ?>st<?php echo $st;?>.html',
                    reader: {
                        type: 'json',
                        root: 'dat'
                    }
                },
                autoLoad: true,
            });
            //设置分页
            var buttons = [
                 <?php  echo $Elsesky->PageLinkRmb($st,$totalnumbers,$listnum,SITE_URL_MB."mb178/searchkw". $name . "st<:st:>.html");?>
            ];
            
            //导航栏
            var myToolbar = new Ext.Toolbar({
                dock : 'top',
                //title: 'My Toolbar',
                items: buttons
            });
            
            
            var form;
            //设置搜索表单
	        var formBase = {
	            scroll: 'horizontal',
	            url   : 'search.php',
	            //url   : 'searchpics.php',
	            autoRender: true,
	            modal: true,
	            centered: true,
	            hideOnMaskTap: false,
	            standardSubmit : true,
	            height: 0,
	            width:0,
	            items: {
	                            xtype: 'textfield',
	                            name : 'name',
	                            useClearIcon: true,
	                            autoCapitalize : false,
	                            labelWidth: '30%'
	            },
	            cls:'loading'
	                        
	        };
	        
	        form = new Ext.form.FormPanel(formBase);
	        //搜索栏
            var mySearchbar = new Ext.Toolbar({
                dock : 'bottom',
                //title: 'My Toolbar',
                items: [form,
                	{
	                    xtype: 'searchfield',
	                    name : 'search',
	                    placeHolder: '输入关键字搜索'
	                    //label: '搜索',
                    },
                        {
                            xtype: 'button',
                            text: '搜索',
                            ui: 'confirm-round',
                            handler: function() {
                            	//将search值传给form
                            	var ff = document.getElementsByName("name");
                                var kw = document.getElementsByName('search');
                                ff[0].value=kw[0].value;
                                form.submit({
                                    waitMsg : {message:'搜索中，请稍候…', cls : 'loading'}
                                });
                            }
                        }],
            	height: 60
            });
            
            var list = new Ext.List({
                fullscreen: true,
                itemTpl : '<div class="contact2"><font color="red"><strong>{nName}</strong></font>&nbsp;更新:{upDate}</div>',
                grouped : true,
                
                selModel: {
                    mode: 'SINGLE',
                    allowDeselect: true
                },
                onItemDisclosure: {
                scope: 'test',
                handler: function(record, btn, index) {
                    //设置点击转向
                        //alert(record.get('id'));
                        window.location=record.get('id');
                 }
                },
                scroll: 'both',
                store: store
            });
            var myPanel = new Ext.Panel({
                dockedItems: [myToolbar,list,mySearchbar],
                fullscreen : true,
                
                //html       : 'Test Panel'
            });
            myPanel.show();
            
            
            //list.show();
    }
});
